package com.sitech.ibnms.c3p.service;

import com.sitech.ibnms.c3p.Application;
import com.sitech.ibnms.c3p.domain.CronScheduleJob;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.ignite.services.ServiceContext;

/**
 * Created by leo on 16/3/1.
 */
public class IgniteC3PScheduleServiceImpl extends IgniteService implements C3pScheduleService {

    private C3pScheduleService service;

    @Override
    public void execute(ServiceContext ctx) throws Exception {
        super.execute(ctx);
        service = Application.getBean(C3pScheduleService.class);
    }

    @Override
    public String scheduleTask(String taskId, String userId, String cronExpression) {
        return service.scheduleTask(taskId, userId, cronExpression);
    }

    @Override
    public String scheduleTask(CronScheduleJob setting) {
        return service.scheduleTask(setting);
    }

    @Override
    public String scheduleTasksSecondsDelay(String cronExpression, String userId, Pair<Integer, String>... tasks) {
        return service.scheduleTasksSecondsDelay(cronExpression, userId, tasks);
    }

    @Override
    public boolean unscheduleTask(String... scheduleIds) {
        return service.unscheduleTask(scheduleIds);
    }

    @Override
    public boolean checkExists(String scheduleId) {
        return service.checkExists(scheduleId);
    }
}
